﻿using System;
using UnityEngine;

// Token: 0x020003FB RID: 1019
public class Singleton<T> : MonoBehaviour where T : MonoBehaviour
{
	// Token: 0x17000271 RID: 625
	// (get) Token: 0x06001967 RID: 6503 RVA: 0x000A4270 File Offset: 0x000A2470
	public static T Instance
	{
		get
		{
			if (!Singleton<T>.instance)
			{
				Singleton<T>.instance = UnityEngine.Object.FindObjectOfType<T>();
			}
			return Singleton<T>.instance;
		}
	}

	// Token: 0x06001968 RID: 6504 RVA: 0x000A4298 File Offset: 0x000A2498
	public static bool IsInstance()
	{
		return Singleton<T>.instance != null;
	}

	// Token: 0x06001969 RID: 6505 RVA: 0x000A42AC File Offset: 0x000A24AC
	protected virtual void Awake()
	{
		this.CheckInstance();
	}

	// Token: 0x0600196A RID: 6506 RVA: 0x000A42B8 File Offset: 0x000A24B8
	protected bool CheckInstance()
	{
		if (this == Singleton<T>.Instance)
		{
			return true;
		}
		UnityEngine.Object.Destroy(this);
		return false;
	}

	// Token: 0x04001CB7 RID: 7351
	private static T instance;
}
